package com.ruoyi.yijing.service.impl;

import java.util.List;

import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.yijing.mapper.CustomerInfoAccountTokenMapper;
import com.ruoyi.yijing.domain.CustomerInfoAccountToken;
import com.ruoyi.yijing.service.ICustomerInfoAccountTokenService;

/**
 * 客户信息TOKENService业务层处理
 * 
 * @author ruoyi
 * @date 2024-02-03
 */
@Service
public class CustomerInfoAccountTokenServiceImpl implements ICustomerInfoAccountTokenService 
{
    @Autowired
    private CustomerInfoAccountTokenMapper customerInfoAccountTokenMapper;

    @Autowired
    public RedisCache redisService;

    /**
     * 查询客户信息TOKEN
     * 
     * @param tokenId 客户信息TOKEN主键
     * @return 客户信息TOKEN
     */
    @Override
    public CustomerInfoAccountToken selectCustomerInfoAccountTokenByTokenId(Long tokenId)
    {
        return customerInfoAccountTokenMapper.selectCustomerInfoAccountTokenByTokenId(tokenId);
    }

    /**
     * 查询客户信息TOKEN列表
     * 
     * @param customerInfoAccountToken 客户信息TOKEN
     * @return 客户信息TOKEN
     */
    @Override
    public List<CustomerInfoAccountToken> selectCustomerInfoAccountTokenList(CustomerInfoAccountToken customerInfoAccountToken)
    {
        return customerInfoAccountTokenMapper.selectCustomerInfoAccountTokenList(customerInfoAccountToken);
    }

    /**
     * 新增客户信息TOKEN
     * 
     * @param customerInfoAccountToken 客户信息TOKEN
     * @return 结果
     */
    @Override
    public int insertCustomerInfoAccountToken(CustomerInfoAccountToken customerInfoAccountToken)
    {
        customerInfoAccountToken.setCreateTime(DateUtils.getNowDate());
        return customerInfoAccountTokenMapper.insertCustomerInfoAccountToken(customerInfoAccountToken);
    }

    /**
     * 修改客户信息TOKEN
     * 
     * @param customerInfoAccountToken 客户信息TOKEN
     * @return 结果
     */
    @Override
    public int updateCustomerInfoAccountToken(CustomerInfoAccountToken customerInfoAccountToken)
    {
        String key = CacheConstants.LOGIN_TOKEN_KEY_CUSTOMER + customerInfoAccountToken.getAccessToken();
        redisService.deleteObject(key);
        return customerInfoAccountTokenMapper.updateCustomerInfoAccountToken(customerInfoAccountToken);
    }

    /**
     * 批量删除客户信息TOKEN
     * 
     * @param tokenIds 需要删除的客户信息TOKEN主键
     * @return 结果
     */
    @Override
    public int deleteCustomerInfoAccountTokenByTokenIds(Long[] tokenIds)
    {
        return customerInfoAccountTokenMapper.deleteCustomerInfoAccountTokenByTokenIds(tokenIds);
    }

    /**
     * 删除客户信息TOKEN信息
     * 
     * @param tokenId 客户信息TOKEN主键
     * @return 结果
     */
    @Override
    public int deleteCustomerInfoAccountTokenByTokenId(Long tokenId)
    {
        return customerInfoAccountTokenMapper.deleteCustomerInfoAccountTokenByTokenId(tokenId);
    }
}
